package com.aspose.cells;

class zabu {
   private zzi a;
   private zagv b;
   private zaay c;
   private zahn[] d;
   private zagu[] e;
   private int f;
   private boolean g = false;
   private boolean h = false;
   private int i = 1;
   private int j = 1;
   private int k = 0;
   private int l = 0;
   private int m = 0;
   private int n;
   private int o;
   private int p;

   public zabu(zzi var1, zaay var2) {
      this.a = var1;
      this.c = var2;
      this.b = var1.l().c();
      this.d = new zahn[var1.m()];
      this.e = new zagu[this.d.length];
      this.n = this.d.length;
      this.o = this.n;
      this.p = this.n;
   }

   public void a(int var1, zagu var2) {
      this.e[var1] = var2;
      if (this.c.k) {
         this.c.m &= var2.b(this.c, this.b.b(var1) == 64);
      }

   }

   public void a(int var1, zahn var2) {
      if (var2.l()) {
         this.e[var1] = var2.a(0, 0);
         if (this.c.k) {
            this.c.m &= this.a.n()[var1].b(this.c, this.b.b(var1) == 64);
         }

      } else {
         this.d[var1] = var2;
         if (var2.m()) {
            if (this.c.k) {
               if (var2.x()) {
                  this.c.m &= -2;
               }

               if (this.h) {
                  if (var2.y() != ((this.f & 2) == 0)) {
                     this.c.m &= -3;
                  }
               } else {
                  this.f = var2.y() ? 1 : 3;
               }
            }

            ++this.k;
            if (this.k == 1) {
               this.n = var1;
            }

            if (this.j > 1) {
               if (var2.d() != this.j) {
                  this.g = true;
                  if (this.c.k) {
                     this.c.m &= -3;
                  }

                  if (var2.d() > this.j) {
                     this.j = var2.d();
                  }
               }
            } else {
               this.j = var2.d();
            }
         } else if (var2.n()) {
            if (this.c.k) {
               if (var2.y()) {
                  this.c.m &= -3;
               }

               if (this.h) {
                  if (var2.x() != ((this.f & 1) == 0)) {
                     this.c.m &= -2;
                  }
               } else {
                  this.f = var2.x() ? 2 : 3;
               }
            }

            ++this.l;
            if (this.l == 1) {
               this.o = var1;
            }

            if (this.i > 1) {
               if (var2.c() != this.i) {
                  this.g = true;
                  if (this.c.k) {
                     this.c.m &= -2;
                  }

                  if (var2.c() > this.i) {
                     this.i = var2.c();
                  }
               }
            } else {
               this.i = var2.c();
            }
         } else {
            if (this.c.k) {
               if (this.h) {
                  if (var2.x() != ((this.f & 1) == 0)) {
                     this.c.m &= -2;
                  }

                  if (var2.y() != ((this.f & 2) == 0)) {
                     this.c.m &= -3;
                  }
               } else if (var2.x()) {
                  if (var2.y()) {
                     this.f = 0;
                  } else {
                     this.f = 2;
                  }
               } else if (var2.y()) {
                  this.f = 1;
               } else {
                  this.f = 3;
               }
            }

            ++this.m;
            if (this.m == 1) {
               this.p = var1;
            }

            if (this.i > 1) {
               if (var2.c() != this.i) {
                  this.g = true;
                  if (this.c.k) {
                     this.c.m &= -2;
                  }

                  if (var2.c() > this.i) {
                     this.i = var2.c();
                  }
               }
            } else {
               this.i = var2.c();
            }

            if (this.j > 1) {
               if (var2.d() != this.j) {
                  this.g = true;
                  if (this.c.k) {
                     this.c.m &= -3;
                  }

                  if (var2.d() > this.j) {
                     this.j = var2.d();
                  }
               }
            } else {
               this.j = var2.d();
            }
         }

      }
   }

   zagu[] a() {
      return this.e;
   }

   public zahn b() {
      int var1;
      boolean var3;
      int var6;
      int var7;
      int var8;
      zlg var12;
      zahn[] var13;
      int var15;
      zahn var16;
      int var17;
      Object var18;
      zahn var19;
      int[] var20;
      if (this.i == 1) {
         if (this.j == 1) {
            return null;
         } else {
            switch(this.k) {
            case 1:
               return new zawt(this.d[this.n], new zlh(this.c, this.a, this.e, this.c.g, this.c.h, this.n), this.c);
            case 2:
               var1 = this.n + 1;
               if (this.e.length > 2 && this.d[var1] == null) {
                  ++var1;

                  while(this.d[var1] == null) {
                     ++var1;
                  }
               }

               return zayc.a(this.d[this.n], this.d[var1], this.c, new zli(this.c, this.a, this.e, this.c.g, this.c.h, this.n, var1));
            default:
               if (this.k != this.d.length) {
                  var13 = new zahn[this.k];
                  var20 = null;
                  var3 = false;
                  var17 = 0;

                  for(var6 = 0; var6 < this.d.length; ++var6) {
                     var16 = this.d[var6];
                     if (var16 != null) {
                        if (this.g && var16.d() < this.j) {
                           var16 = zayc.a(var16, this.j);
                           this.d[var6] = var16;
                        }

                        if (var3) {
                           var20[var17] = var6;
                        }

                        var13[var17] = var16;
                        ++var17;
                     } else if (!var3 && var17 > 0 && var17 < this.k) {
                        var3 = true;
                        var20 = new int[this.k];
                        var7 = var6 - var17;
                        var20[0] = var7++;
                        if (var7 < var6) {
                           var8 = 1;

                           while(true) {
                              var20[var8] = var7++;
                              if (var7 == var6) {
                                 break;
                              }

                              ++var8;
                           }
                        }
                     }
                  }

                  if (var3) {
                     var18 = new zle(this.c, this.a, this.e, this.c.g, this.c.h, var20);
                  } else if (this.n > 0) {
                     var18 = new zlf(this.c, this.a, this.e, this.c.g, this.c.h, this.n, this.k);
                  } else {
                     var18 = new zlg(this.c, this.a, this.e, this.c.g, this.c.h, this.k);
                  }

                  return new zawr(var13, (zagj)var18, this.c);
               } else {
                  var12 = new zlg(this.c, this.a, this.e, this.c.g, this.c.h, this.k);
                  if (this.g) {
                     for(var15 = 0; var15 < this.d.length; ++var15) {
                        var19 = this.d[var15];
                        if (var19 != null && var19.d() < this.j) {
                           this.d[var15] = zayc.a(var19, this.j);
                        }
                     }
                  }

                  return new zawr(this.d, var12, this.c);
               }
            }
         }
      } else if (this.j == 1) {
         switch(this.l) {
         case 1:
            return new zawt(this.d[this.o], new zlh(this.c, this.a, this.e, this.c.g, this.c.h, this.o), this.c);
         case 2:
            var1 = this.o + 1;
            if (this.e.length > 2 && this.d[var1] == null) {
               ++var1;

               while(this.d[var1] == null) {
                  ++var1;
               }
            }

            return zayc.a(this.d[this.o], this.d[var1], this.c, new zli(this.c, this.a, this.e, this.c.g, this.c.h, this.o, var1));
         default:
            if (this.l != this.d.length) {
               var13 = new zahn[this.l];
               var20 = null;
               var3 = false;
               var17 = 0;

               for(var6 = 0; var6 < this.d.length; ++var6) {
                  var16 = this.d[var6];
                  if (var16 != null) {
                     if (this.g && var16.c() < this.i) {
                        var16 = zayc.a(var16, this.i);
                        this.d[var6] = var16;
                     }

                     if (var3) {
                        var20[var17] = var6;
                     }

                     var13[var17] = var16;
                     ++var17;
                  } else if (!var3 && var17 > 0 && var17 < this.l) {
                     var3 = true;
                     var20 = new int[this.l];
                     var7 = var6 - var17;
                     var20[0] = var7++;
                     if (var7 < var6) {
                        var8 = 1;

                        while(true) {
                           var20[var8] = var7++;
                           if (var7 == var6) {
                              break;
                           }

                           ++var8;
                        }
                     }
                  }
               }

               if (var3) {
                  var18 = new zle(this.c, this.a, this.e, this.c.g, this.c.h, var20);
               } else if (this.o > 0) {
                  var18 = new zlf(this.c, this.a, this.e, this.c.g, this.c.h, this.o, this.l);
               } else {
                  var18 = new zlg(this.c, this.a, this.e, this.c.g, this.c.h, this.l);
               }

               return new zawr(var13, (zagj)var18, this.c);
            } else {
               var12 = new zlg(this.c, this.a, this.e, this.c.g, this.c.h, this.l);
               if (this.g) {
                  for(var15 = 0; var15 < this.d.length; ++var15) {
                     var19 = this.d[var15];
                     if (var19 != null && var19.c() < this.i) {
                        this.d[var15] = zayc.a(var19, this.i);
                     }
                  }
               }

               return new zawr(this.d, var12, this.c);
            }
         }
      } else {
         var1 = this.m + this.k + this.l;
         switch(var1) {
         case 1:
            return new zawt(this.d[this.p], new zlh(this.c, this.a, this.e, this.c.g, this.c.h, this.p), this.c);
         case 2:
            int var2;
            if (this.p == 2) {
               var2 = this.p + 1;
               if (this.e.length > 2 && this.d[var2] == null) {
                  ++var2;

                  while(this.d[var2] == null) {
                     ++var2;
                  }
               }
            } else {
               var2 = this.n > 0 ? this.n : this.o;
            }

            return zayc.a(this.d[this.p], this.d[var2], this.c, new zli(this.c, this.a, this.e, this.c.g, this.c.h, this.p, var2));
         default:
            zahn[] var14 = null;
            int[] var4;
            if (this.p <= this.n && this.p <= this.o && this.n <= this.o) {
               var3 = false;
               var4 = null;
            } else {
               var3 = true;
               var4 = new int[var1];
            }

            if (var3 || var1 != this.d.length) {
               var14 = new zahn[var1];
            }

            int var5 = 0;
            var6 = 0;
            var7 = this.m;
            var8 = this.m + this.k;
            int var9 = var8;

            for(int var11 = 0; var11 < this.d.length; ++var11) {
               zahn var10 = this.d[var11];
               if (var10 != null) {
                  ++var5;
                  if (var10.m()) {
                     if (this.g && var10.d() < this.j) {
                        var10 = zayc.a(var10, this.j);
                        this.d[var11] = var10;
                     }

                     if (var3) {
                        var4[var7] = var11;
                        var14[var7] = var10;
                        ++var7;
                     } else if (var6 < this.m) {
                        var3 = true;
                        var4 = new int[var1];
                        if (var14 == null) {
                           var14 = new zahn[var1];
                           this.a(var4, var6, var11, var14);
                        } else {
                           this.a(var4, var6, var11, (zahn[])null);
                        }

                        var14[var7] = var10;
                        ++var7;
                     }
                  } else if (var10.n()) {
                     if (this.g && var10.c() < this.i) {
                        var10 = zayc.a(var10, this.i);
                        this.d[var11] = var10;
                     }

                     if (var3) {
                        var4[var8] = var11;
                        var14[var8] = var10;
                        ++var8;
                     } else if (var6 < this.m) {
                        var3 = true;
                        var4 = new int[var1];
                        if (var14 == null) {
                           var14 = new zahn[var1];
                           this.a(var4, var6, var11, var14);
                        } else {
                           this.a(var4, var6, var11, (zahn[])null);
                        }

                        var14[var8] = var10;
                        ++var8;
                     } else if (var7 < var9) {
                        var3 = true;
                        var4 = new int[var1];
                        if (var14 == null) {
                           var14 = new zahn[var1];
                           this.a(var4, var6 + var7, var11, var14);
                        } else {
                           this.a(var4, var6 + var7, var11, (zahn[])null);
                        }

                        var14[var8] = var10;
                        ++var8;
                     }
                  } else {
                     if (this.g) {
                        if (var10.c() < this.i) {
                           if (var10.d() < this.j) {
                              var10 = zayc.b(var10, this.i, this.j);
                           } else {
                              var10 = zayc.c(var10, this.i);
                           }

                           this.d[var11] = var10;
                        } else if (var10.d() < this.j) {
                           var10 = zayc.b(var10, this.j);
                           this.d[var11] = var10;
                        }
                     }

                     if (var3) {
                        var4[var6] = var11;
                        var14[var6] = var10;
                        ++var6;
                     }
                  }
               } else if (!var3 && var6 > 0 && var5 < var1) {
                  var3 = true;
                  var4 = new int[var1];
                  if (var14 == null) {
                     var14 = new zahn[var1];
                     this.a(var4, var6 + var7 + var8, var11, var14);
                  } else {
                     this.a(var4, var6 + var7 + var8, var11, (zahn[])null);
                  }
               }
            }

            Object var21;
            if (var3) {
               var21 = new zle(this.c, this.a, this.e, this.c.g, this.c.h, var4);
            } else if (this.p > 0) {
               var21 = new zlf(this.c, this.a, this.e, this.c.g, this.c.h, this.p, var1);
            } else {
               var21 = new zlg(this.c, this.a, this.e, this.c.g, this.c.h, var1);
            }

            if (this.m == var1) {
               return new zaws(var14, (zagj)var21, this.c);
            } else {
               return new zawq(var14, (zagj)var21, this.c, this.i, this.j, this.m, var9);
            }
         }
      }
   }

   private void a(int[] var1, int var2, int var3, zahn[] var4) {
      switch(var2) {
      case 0:
         break;
      case 1:
         if (var4 != null) {
            --var3;
            var1[0] = var3;
            var4[0] = this.d[var3];
         } else {
            var1[0] = var3 - 1;
         }
         break;
      case 2:
         if (var4 != null) {
            --var3;
            var1[1] = var3;
            var4[1] = this.d[var3];
            --var3;
            var1[0] = var3;
            var4[0] = this.d[var3];
         } else {
            var1[0] = var3 - 2;
            var1[1] = var3 - 1;
         }
         break;
      default:
         int var5 = var3 - var2;
         int var6 = 0;
         if (var4 != null) {
            while(true) {
               var1[var6] = var5;
               var4[var6] = this.d[var6];
               ++var6;
               if (var6 == var2) {
                  break;
               }

               ++var5;
            }
         } else {
            while(true) {
               var1[var6] = var5;
               ++var6;
               if (var6 == var2) {
                  break;
               }

               ++var5;
            }
         }
      }

   }
}
